<?php


namespace app\home\controller;


use app\base\BaseController;
use think\facade\Db;

/**
 * Class SfDetail
 * @package app\home\controller
 * 收发明细
 */
class SfDetail extends BaseController
{
//    protected $table='material_dossier';
    protected $title='收发明细';

    public function index()
    {

        $param=$this->param;
        if (request()->isAjax()) {
            $se_type=$param['se_type']??1;
//            $where[]=['deleted','=',0];
            $where[]=['status','=',2];
            $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
            if ($se_type==1){
                $table='ruku_view';
            }else{
                $table='chuku_view';
            }
            foreach (['orderNum','pName','mdTypeName','bar_code','mdName','specs','wName'] as $v){
                if (isset($param[$v])&&$param[$v]){
                    $where[]=[$v,'like','%'.$param[$v].'%'];
                }
            }
            if (isset($param['yw_type'])&&$param['yw_type']){
                $where[]=['yw_type','=',$param['yw_type']];
            }
            if (isset($param['doDate'])&&$param['doDate']){
                $dates=explode('~',$param['doDate']);
                $where[]=['doDate','between',$dates];
            }
            $list = Db::name($table)
                ->where($where)
                ->field("*")
                ->order('doDate Desc')
                ->paginate($rows);
            return table_assign(0, '', $list);
        } else {
            return view();
        }

}
}